﻿using System;
using UnityEngine;

// Token: 0x02000365 RID: 869
public class SimpleSunController : MonoBehaviour
{
	// Token: 0x17000387 RID: 903
	// (get) Token: 0x0600167B RID: 5755 RVA: 0x00091DED File Offset: 0x0008FFED
	public static Vector3 SunDirection
	{
		get
		{
			return SimpleSunController.sunDirection;
		}
	}

	// Token: 0x17000388 RID: 904
	// (get) Token: 0x0600167C RID: 5756 RVA: 0x00091DF4 File Offset: 0x0008FFF4
	// (set) Token: 0x0600167D RID: 5757 RVA: 0x00091DFB File Offset: 0x0008FFFB
	public static bool UseRealtimeDayAndNight
	{
		get
		{
			return SimpleSunController.useRealtimeDayAndNight;
		}
		set
		{
			SimpleSunController.useRealtimeDayAndNight = value;
		}
	}

	// Token: 0x17000389 RID: 905
	// (get) Token: 0x0600167E RID: 5758 RVA: 0x00091E03 File Offset: 0x00090003
	// (set) Token: 0x0600167F RID: 5759 RVA: 0x00091E0A File Offset: 0x0009000A
	public static float DayTimeScale
	{
		get
		{
			return SimpleSunController.dayTimeScale;
		}
		set
		{
			SimpleSunController.dayTimeScale = value;
		}
	}

	// Token: 0x1700038A RID: 906
	// (get) Token: 0x06001680 RID: 5760 RVA: 0x00091E12 File Offset: 0x00090012
	// (set) Token: 0x06001681 RID: 5761 RVA: 0x00091E19 File Offset: 0x00090019
	public static float SunX
	{
		get
		{
			return SimpleSunController.sunX;
		}
		set
		{
			SimpleSunController.sunX = value;
			SimpleSunController.UpdateSunRotation();
		}
	}

	// Token: 0x1700038B RID: 907
	// (get) Token: 0x06001682 RID: 5762 RVA: 0x00091E26 File Offset: 0x00090026
	// (set) Token: 0x06001683 RID: 5763 RVA: 0x00091E2D File Offset: 0x0009002D
	public static float SunY
	{
		get
		{
			return SimpleSunController.sunY;
		}
		set
		{
			SimpleSunController.sunY = value;
			SimpleSunController.UpdateSunRotation();
		}
	}

	// Token: 0x1700038C RID: 908
	// (get) Token: 0x06001684 RID: 5764 RVA: 0x00091E3A File Offset: 0x0009003A
	// (set) Token: 0x06001685 RID: 5765 RVA: 0x00091E41 File Offset: 0x00090041
	public static GameObject Sun
	{
		get
		{
			return SimpleSunController.sun;
		}
		set
		{
			SimpleSunController.sun = value;
		}
	}

	// Token: 0x06001686 RID: 5766 RVA: 0x00091E4C File Offset: 0x0009004C
	private void Start()
	{
		Light[] array = UnityEngine.Object.FindObjectsOfType<Light>();
		foreach (Light light in array)
		{
			if (light.type == LightType.Directional)
			{
				SimpleSunController.Sun = light.gameObject;
				SimpleSunController.sunX = SimpleSunController.Sun.transform.localEulerAngles.x;
				SimpleSunController.sunY = SimpleSunController.Sun.transform.localEulerAngles.y;
			}
		}
	}

	// Token: 0x06001687 RID: 5767 RVA: 0x00091ECA File Offset: 0x000900CA
	private void Update()
	{
		SimpleSunController.sunDirection = SimpleSunController.Sun.transform.eulerAngles;
		if (SimpleSunController.UseRealtimeDayAndNight)
		{
			SimpleSunController.SunX += Time.deltaTime * SimpleSunController.DayTimeScale;
		}
	}

	// Token: 0x06001688 RID: 5768 RVA: 0x00091F00 File Offset: 0x00090100
	private static void UpdateSunRotation()
	{
		if (SimpleSunController.SunX > 360f)
		{
			SimpleSunController.sunX = SimpleSunController.SunX - 360f;
		}
		if (SimpleSunController.SunY > 360f)
		{
			SimpleSunController.sunY = SimpleSunController.SunY - 360f;
		}
		SimpleSunController.Sun.transform.localEulerAngles = new Vector3(SimpleSunController.sunX, SimpleSunController.sunY, 0f);
	}

	// Token: 0x04001923 RID: 6435
	private static Vector3 sunDirection = new Vector3(0f, 0f, 0f);

	// Token: 0x04001924 RID: 6436
	private static bool useRealtimeDayAndNight;

	// Token: 0x04001925 RID: 6437
	private static float dayTimeScale = 0.1f;

	// Token: 0x04001926 RID: 6438
	private static float sunX;

	// Token: 0x04001927 RID: 6439
	private static float sunY;

	// Token: 0x04001928 RID: 6440
	private static GameObject sun;
}
